﻿using System;
using System.Collections.Generic;

using System.Text;
using ModuleDALCore;
using QUANLYCHAMCONG.DAO.Core;
using QUANLYCHAMCONG.BL.Entities;
using System.Data;

namespace QUANLYCHAMCONG.DAO.DAO
{
    public class CHAMCONGDAO:DALBase
    {
        CHAMCONG cc;
         private string _SpName;
        public string SpName
        {
            get { return "SpCHAMCONG"; }
            set { _SpName = value; }
        }
        public CHAMCONGDAO()
        {
            OpenConnect();
        }
        public bool Insert(CHAMCONG cc)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cc, null), ConvertClassToArray.GetValues(cc,1)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Insert(CHAMCONG cc,int FLAG)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cc, null), ConvertClassToArray.GetValues(cc, 5)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Update(CHAMCONG cc)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cc, null), ConvertClassToArray.GetValues(cc,2)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Delete(CHAMCONG cc)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cc, null), ConvertClassToArray.GetValues(cc,3)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public DataTable SelectByPK(CHAMCONG cc)
        {
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(cc, null), ConvertClassToArray.GetValues(cc,4));
            }
            catch
            {
                return null;
            }
        }
        public DataTable SelectALL()
        {
            cc = new CHAMCONG();
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(cc, null), ConvertClassToArray.GetValues(cc,0));
            }
            catch
            {
                return null;
            }
        }
        public int GetID()
        {
            cc = new CHAMCONG();
            try
            {
                return DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cc, null), ConvertClassToArray.GetValues(cc, 5), DBConnectionState.CloseOnExit);
            }
            catch
            {
                return 0;
            }
        }
    }
}
